#include <stdio.h>
#include <string.h>

void  reverseStr(char * str,int left,int right)
{
    right--;
    while (left<right)
    {
        char tmp = str[left];
        str[left] = str[right];
        str[right] = tmp;

        left++;
        right--;
    }
}

void  reverseWord(char * str)
{
    int length = strlen(str);
    int start = 0;
    int end = 0;
    for(int idx = 0;idx < length;idx++)
    {
        if(str[idx] == ' ')
        {
        end = idx;
        reverseStr(str,start,end);
        start = end+1;
        }
    }
    reverseStr(str,start,length);

}


int main()
{
    char str[] = "hello world";
    reverseWord(str);
    printf("%s\n",str);
}